package com.appbee.media.server;

import java.io.IOException;
import java.util.logging.Logger;

import javax.inject.Inject;
import javax.inject.Singleton;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.blobstore.BlobstoreService;

@Singleton
public class ImageService extends HttpServlet
{
	private static final Logger log = Logger.getLogger(ImageUploadService.class.getName());
	private BlobstoreService blobstoreService;
	
	@Inject
	public ImageService(BlobstoreService blobstoreService)
	{
		this.blobstoreService = blobstoreService;
	}
	

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException
	{
		log.info("service blob-key: "+req.getParameter("blob-key"));
		BlobKey blobKey = new BlobKey(req.getParameter("blob-key"));
        blobstoreService.serve(blobKey, resp);
	}

}
